package com.jcli._自己的想法;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * User
 * 使用java编写一个swing程序，获取OneNote2016中笔记本的名称，分区的名称以及页面的名称，已思维导图的形状展示出来。
 */
public class OneNoteViewer extends JFrame {

    public OneNoteViewer() {
        initializeUI();
    }

    private void initializeUI() {
        setTitle("OneNote Viewer");
        setSize(600, 400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Create Swing components and add them to the frame

        // Example: Add a button
        JButton getDataButton = new JButton("Get OneNote Data");
        getDataButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // Handle button click event
                fetchDataFromOneNote();
            }
        });

        // Example: Add a tree to display data
        JTree dataTree = new JTree();

        // Example: Add a panel for drawing mind map shapes
        JPanel drawingPanel = new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                // Implement drawing logic here
            }
        };

        // Layout the components
        setLayout(new BorderLayout());
        add(getDataButton, BorderLayout.NORTH);
        add(new JScrollPane(dataTree), BorderLayout.WEST);
        add(drawingPanel, BorderLayout.CENTER);
    }

    private void fetchDataFromOneNote() {
        // Implement logic to fetch data from OneNote
        // Use HTTP requests to Microsoft Graph API
        // Parse the JSON response
        // Update the Swing components with the retrieved data
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new OneNoteViewer().setVisible(true);
            }
        });
    }
}
